// Authorization/index.js
Component({
  data: {
    islogin: false
  },
  lifetimes: {
    attached() {
      const token = getApp().token
      this.setData({
        islogin: !!token
      })
      if (!this.data.islogin) {
        const pageStack = getCurrentPages()
        const currentPage = pageStack[pageStack.length - 1]
        wx.redirectTo({
          // url: '/pages/login/index'
          url: `/pages/login/index?returnUrl=/${currentPage.route}`
        })
      }
    }
  }
})
